<template>
  <div>
    <van-nav-bar
      title="房屋管理"
      left-text="返回"
      left-arrow
      @click-left="$router.back()"
      class="navColor"
    />
    <div v-if="show" class="falseClass" @click="this.$router.push('/rent/add')">您还没有房源，<span>去发布房源</span>吧~</div>
    <MyCell v-for="item in list" :key="item.id" :item="item" v-else></MyCell>
  </div>
</template>

<script>
import { getHouseList } from '@/api/user'
import MyCell from '@/components/MyCell'
export default {
  data () {
    return {
      list: [],
      show: true
    }
  },
  async created () {
    const t1 = this.$toast.loading({
      message: '加载中...',
      duration: 0,
      forbidClick: true
    })
    const res = await getHouseList()
    // console.log(res)

    if (res) {
      this.show = false
      this.list = res.data.body
      t1.clear()
    //   this.$toast.clear()
    } else {
      this.show = true
    }
  },
  components: { MyCell }
}
</script>

<style lang="less" scoped>
.navColor {
  background-color: #58b67f;

  /deep/.van-icon {
    color: aliceblue;
  }
  /deep/.van-nav-bar__title {
    color: aliceblue;
    font-weight: normal;
  }
}
.falseClass {
    width: 100%;
    height: 150px;
    line-height: 150px;
    font-size: 14px;
    display: inline-block;
    text-align: center;
    span{
        color: #58b67f;
    }
}
</style>
